#include <thread.h>

#include <iostream>
using std::cout;
using std::endl;

#include <string>
using std::string;

//To apply threading create a class inheriting Thread with a new run()
class couter: public Thread
{
	//We define the threaded function(run)
	void run(void *t)
	{
		int i, j;
		cout << endl << "==Thread started==" << endl;
		for(i = 0; i < 1000; i++){
			cout << i << " ";
			for(j=0; j < 60000; j++);
		}
		cout << endl << "==Thread finished==" << endl;
	}
};

int main(int argc, char *argv[])
{
	int i;
	couter a;
	//Start
	a.start();
	cout << endl << "Thread 1 started" << endl;
	//Kill
	a.kill();
	cout << endl << "Thread 1 killed" << endl;
	couter b;
	b.start();
	//Wait for thread "b" to finish
	b.wait();
	cout << endl << "All Threads finished" << endl;
	return 0;
}
